import sys

file_name = input("文件名称: ").strip()
file_mode = input("操作模式: ").strip()

try:
    fobj = open(file_name, mode=file_mode)
except FileNotFoundError as e:
    print("文件不存在，检查路径是否正确")
    print(e)
    sys.exit()
except ValueError as e:
    print("文件不支持这种操作")
    print(e)
    sys.exit()

data = fobj.read()
print(data)

fobj.close()